home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Name: Rosette
- ** Author: Paul Manias
- ** Copyright: DreamWorld Productions (c) 1997
- ** SAS/C: sc Rosette.c link startup=lib:gms.o data=far opt math=standard nostackcheck
- ** Doc: Draws various rosette patterns.
- **
- **
- */
-
- #include <proto/games.h>
- #include <math.h>
-
- extern struct GMSBase *GMSBase;
- APTR PREFSNAME = DEFAULT;
-
- struct GameScreen *screen;
-
- void Rosette(void);
-
- #define AMTCOLOURS 32
-
- ULONG palette[AMTCOLOURS] = {
- 0x000000,0x101010,0x171717,0x202020,0x272727,0x303030,0x373737,0x404040,
- 0x474747,0x505050,0x575757,0x606060,0x676767,0x707070,0x777777,0x808080,
- 0x878787,0x909090,0x979797,0xa0a0a0,0xa7a7a7,0xb0b0b0,0xb7b7b7,0xc0c0c0,
- 0xc7c7c7,0xd0d0d0,0xd7d7d7,0xe0e0e0,0xe0e0e0,0xf0f0f0,0xf7f7f7,0xffffff
- };
-
- /***********************************************************************************/
-
- void main(void)
- {
- if (screen = AddScreenTags(TAGS_GAMESCREEN,NULL,
- GSA_AmtColours, AMTCOLOURS,
- GSA_Palette, palette,
- TAGEND)) {
-
- ShowScreen(screen);
- InitJoyPorts();
-
- Rosette();
-
- DeleteScreen(screen);
- }
- }
-
- /***********************************************************************************/
-
- void Rosette(void)
- {
- WORD offsetx = (screen->ScrWidth/2);
- WORD offsety = (screen->ScrHeight/2);
-
- /* Experiment with the values below */
- double inside=3.0, radius=100.0, outside=3.0, f=0.5, edges=10;
-
- double t,angle,x,y;
-
- for (t = -inside/10; t < (outside/10); t += 0.1) {
- for (angle=0; angle < (2*PI); angle += 0.01) {
- x = radius*cos(angle)+t*radius*cos(angle*edges);
- y = radius*sin(angle)+t*radius*sin(angle*edges);
- DrawPixel(screen->Bitmap,(WORD)(x+offsetx),(WORD)(y*f+offsety),10);
- }
- }
- WaitLMB();
- }
-
-